import { createRouter, createWebHistory } from "vue-router";
import Layout from "@/layout/index.vue";

const routes = [
  { path: "/login", component: () => import("@/views/login/index.vue") },
  { path: "/register", component: () => import("@/views/login/register.vue") },
  {
    path: "/",
    component: Layout,
    redirect: '/order/add',
    children: [
      {
        path: "/order/list",
        name: "order_list",
        meta: {
          title: "下单列表",
        },
        component: () => import("@/views/orders/index.vue"),
      },
      {
        path: "/order/add",
        name: "order_add",
        meta: {
          title: "下单",
        },
        component: () => import("@/views/orders/add.vue"),
      },
      // {
      //   path: "/mine",
      //   name: "mine",
      //   meta: {
      //     title: "我的",
      //   },
      //   component: () => import("@/views/mine/index.vue"),
      // },
    ],
  },
  {
    path: "/order/detail/:id",
    name: "order_detail",
    meta: {
      title: "订单跟踪",
    },
    component: () => import("@/views/orders/detail.vue"),
  },
  {
    path: "/order/edit/:orderId",
    name: "order_edit",
    meta: {
      title: "订单编辑",
    },
    component: () => import("@/views/orders/edit.vue"),
  },
  // {
  //   path: "/mine/address",
  //   name: "mine-address",
  //   meta: {
  //     title: "地址管理",
  //   },
  //   component: () => import("@/views/mine/address.vue"),
  // },
  {
    path: "/admin/order-list",
    name: "admin-order-list",
    meta: {
      title: "订单查询",
    },
    component: () => import("@/views/orders/admin-list.vue"),
  },
];

export const router = createRouter({
  history: createWebHistory(),
  routes,
});
